import { defineStore } from "pinia";

let store = defineStore("UserStore", {
    state: () => {
        return  {
            empno:'',
            root:0,
            account: '',
            deptno:'',
            email:''
        }
    },
    getters: {
        getDeptno: function (state){
            return state.deptno;
        },
        getEmpno: function (state){
            return state.empno;
        },
        getRoot: function (state){
            return state.root;
        },
        getAccount: function (state){
            return state.account;
        },
        getEmail: function (state){
            return state.email;
        }
    },
    actions: {
        saveDeptno: function (deptno: string){
            this.deptno = deptno;
        },
        saveEmpno: function (empno: string){
            this.empno = empno;
        },
        saveRoot: function (root: number){
            this.root = root;
        },
        saveAccount: function (account: string){
            this.account = account;
        },
        saveEmail: function(email: string){
            this.email = email;
        }
    },
    persist: {
        storage: sessionStorage
    } 
})

export default store;